package org.gitos.cloud.cmd.controller;

import java.util.Map;

import org.gitos.cloud.domain.comm.Constant;
import org.springframework.web.bind.annotation.RestController;

import com.google.common.collect.Maps;

/**
 * Created by shizhengchu on 15/12/23.
 */
public class BaseController {

	protected Map<String, Object> success() {
		Map<String, Object> ret = Maps.newHashMap();
		ret.put(Constant.RET_STATE, 200);
		ret.put(Constant.RET_DATA, null);
		return ret;
	}

	protected Map<String, Object> success(Object data) {
		Map<String, Object> ret = Maps.newHashMap();
		ret.put(Constant.RET_STATE, 200);
		ret.put(Constant.RET_DATA, data);
		return ret;
	}

	protected Map<String, Object> fail(String msg) {
		Map<String, Object> ret = Maps.newHashMap();
		ret.put(Constant.RET_STATE, 500);
		ret.put(Constant.RET_MSG, msg);
		return ret;
	}

	protected Map<String, Object> fail() {
		Map<String, Object> ret = Maps.newHashMap();
		ret.put(Constant.RET_STATE, 500);
		ret.put(Constant.RET_MSG, "");
		return ret;
	}
}
